//获取应用实例
const app = getApp()

function scodeItem() {
  var array = [];
  for (var i = -20; i <= 20; i++) {
    if (i <= 0) {
      array.push(i);
    } else {
      array.push("+" + i);
    }
  }
  return array;
}

Page({

  /**
   * 页面的初始数据
   */
  data: {
    //imgUrl
    imgUrl:app.globalData.iconImgUrl,
    backImg: app.globalData.iconImgUrl+"arrow-left.svg",
    noAgreeVisible: false,
    type: 'forMyself',
    current: 'tab1',
    StatusBar: app.globalData.StatusBar,
    CustomBar: app.globalData.CustomBar,
    backIcon: true,
    title: "审核详情",
    value: '',
    noAgreeScVisible: false,
    formeImg: [
      app.globalData.iconImgUrl+"timg.jpg",
      app.globalData.iconImgUrl+"timg.jpg",
      app.globalData.iconImgUrl+"timg.jpg"
    ],
    hdTabObj: [
      {
        name: "为自己申请",
        active: "active"
      },
      {
        name: "为他人申请",
        active: ""
      }
    ],
    pickIndex: 0,
    addScode: scodeItem(),
    addScodeIndex: 0,
    addScodeVal: '+10',
    nameIndex: 0,
    tabObj: [
      {
        name: "首页",
        active: "true",
        image: app.globalData.iconImgUrl+"home.svg",
        imageActive: "https://www.zgajf.com/static/images/home-active.svg"
      },
      {
        name: "福利商城",
        active: "",
        image: "https://www.zgajf.com/static/images/mall.svg",
        imageActive: "https://www.zgajf.com/static/images/mall-active.svg"
      },
      {
        name: "认可大厅",
        active: "",
        image: "https://www.zgajf.com/static/images/Approval.svg",
        imageActive: "https://www.zgajf.com/static/images/Approval-active.svg"
      },
      {
        name: "我的",
        active: "",
        image: "https://www.zgajf.com/static/images/mine.svg",
        imageActive: "https://www.zgajf.com/static/images/mine-active.svg"
      }
    ]
  },
  showModal(modalName) {
    this.setData({
      [modalName]: true
    })
  },
  hideModal(modalName) {
    this.setData({
      [modalName]: false
    })
  },
  hideApply() {
    this.hideModal("modalVisible")
  },
  agree() {
    this.showModal("modalVisible")
  },
  noAgree() {
    this.showModal("noAgreeVisible")
  },
  hideAgree() {
    this.hideModal("noAgreeVisible");
    this.showModal("noAgreeScVisible")
  },
  hideNoAgreeSc() {
    this.hideModal("noAgreeScVisible")
  },
  noAgreeInput(e) {
    console.log(e.detail.value)
    this.setData({
      value: e.detail.value
    })
  },
  handleChange({ detail }) {
    this.setData({
      current: detail.key
    });
  },
  TimeChange(e) {
    this.setData({
      time: e.detail.value
    })
  },
  deleteName(e) {
    // console.log(e.target)
    var index = e.target.dataset.index;
    var data = this.data.selectedItem;
    var pickData = this.data.items;
    pickData[index].checked = false;

    // delete data[index];
    data.splice(index, 1)
    console.log(data)
    this.setData({
      selectedItem: data,
      items: pickData
    })
  },
  TimeChange1(e) {
    this.setData({
      time1: e.detail.value
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  },
  p_navTap(param) {
    var index = param.detail.target.dataset.index;
    var item1 = "hdTabObj[" + index + "].active", item2;
    var type;
    if (index === 0) {
      item2 = "hdTabObj[1].active";
      type = "forMyself";
    } else {
      item2 = "hdTabObj[0].active";
      type = "forOther";
    }

    this.setData({
      [item1]: "active",
      [item2]: '',
      type: type
    });
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})